package com.thinkgem.jeesite.modules.monitor.web;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.monitor.zabbix.service.ZabbixApiService;
import com.thinkgem.jeesite.common.utils.DateUtils;

/**
 * 所有监控机器历史问题记录查询
 * 
 * @author WangYuan
 * @date 2016年8月3日下午5:17:30
 */
@Controller
@RequestMapping(value = "${adminPath}/server/issue")
public class IssueReportController {

    @Resource
    private ZabbixApiService service;

    @RequestMapping(value = {"/list", ""})
    public String list(Model model) {

        Map<String, Object> param = new HashMap<>();
        List<Map<String, Object>> list = service.findProblem(param); // 查询参数为空
        for (Map<String, Object> map : list) {
            long dateStr = Long.parseLong(map.get("lastchange").toString())*1000;
            String date = DateUtils.formatDate(new Date(dateStr), "yyyy-MM-dd HH:mm:ss");
            map.put("lastchange", date);
        }
        model.addAttribute("list", list);

        return "modules/monitor/issueReport";
    }

}
